// 导入axios
import axios from 'axios';
// 创建实例
// export var baseUrl = "http://47.109.31.142:9080/";
export var baseUrl = "/";
const reqeust = axios.create({
    // 基础路径，在请求接口会把基础路径加在所有接口的前面
    baseURL: baseUrl,
    timeout: 10000
})

// 请求拦截
reqeust.interceptors.request.use(config => {
    config.headers = config.headers || {}
    config.headers['Content-Type'] = "application/json;charset=UTF-8"
    config.headers['Access-Control-Allow-Origin'] = "http://47.109.31.142"
    config.headers.apiKey = "a92a7db58b234595951bb2b39fcf6430"
    config.params = {
        ...config.params
    }
    config.data = {
        ...config.data
    }

    //  config.headers['Authorization'] = 'dasdasdasdasdas'
    // if (localStorage.getItem('token')) {
    //     config.headers['Authorization'] = `Bearer ${localStorage.getItem("token")}`

    // }
    return config
})
// 响应拦截
reqeust.interceptors.response.use(
    res => {

        // if (res.data.success || res.data) {
        //     return Promise.resolve(res.data)

        // } else {
        //     return Promise.reject(res.data)
        // }
        return Promise.resolve(res)
    },
    error => {

    })


//

export default reqeust